<template>
	<view>
		<topbar title="我的团队" jt_c="2" background="background:#222222;color:#fff;"></topbar>
		<view class="tg_bz dis_f_l_c">
			<image src="../../static/mine/tgbz.png" mode=""></image>
			<view class="dis_f_c_c" @click="go_wen">推广帮助</view>
		</view>
		<view class="content">
			<view class="top dis_f_co">
				<view class="dis_f_l_c">
					<view class="dis_f_sb_c" style="width: 100%;margin-bottom: 44rpx;">
						<view class="dis_f_l_c">
							<view style="margin-right: 32rpx;">当前级别:</view>
							<image v-if="user.level" class="hy_logo" src="../../static/mine/hy.png" mode=""></image>
							<view v-if="user.level" class="hy_vip">{{user.levelname}}</view>
							<view v-else class="hy_pt"></view>
						</view>
						<!-- <view>截止至 {{user.today}}</view> -->
					</view>
				</view>
				<view class="dis_f_sa_c">
					<view class="dis_f_co_c_c">
						<view class="text1">直推({{user.yivip}}单)</view>
						<view class="text2">{{user.usuperior}}人</view>
						<!-- <view class="ck_btn dis_f_c_c">查看</view> -->
					</view>
					<view class="dis_f_co_c_c">
						<view class="text1">二级({{user.ervip}}单)</view>
						<view class="text2">{{user.usuperiors}}人</view>
						<!-- <view class="ck_btn dis_f_c_c">查看</view> -->
					</view>
					<view class="dis_f_co_c_c">
						<view class="text1">团队({{user.teamvip}}单)</view>
						<view class="text2">{{user.team}}人</view>
						<!-- <view class="ck_btn dis_f_c_c">查看</view> -->
					</view>
				</view>
			</view>
			<view style="margin-bottom: 37rpx;">
				<u-tabs :list="list" bg-color="none" active-color="#222222" bar-width="196" bar-height="4"
					inactive-color="#BBBBBB" :is-scroll="false" :current="current" @change="change"></u-tabs>
			</view>
			<view class="dis_f_co">
				<view class="bottom" v-for="(item,index) in vip">
					<view style="margin-bottom: 12rpx;">用户：{{item.mobile}}</view>
					<view style="color: #BBBBBB;font-size: 22rpx;line-height: 32rpx;width: 100%;" class="dis_f_sb_c">
						<view v-if="item.is_youxiao" style="color: #19BE6B;">有效</view>
						<view v-else="" style="color: #FA3534;">无效</view>
						<view>{{item.create_time}}</view>
					</view>
				</view>
			</view>
			<view style="padding-bottom: 100rpx;">
				<u-loadmore :status="status" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
					name: '直推'
				}, 
				{
					name: '二级'
				}, 
				{
					name: '团队'
				}, 
				],
				current: 0,
				hy_level: true,
				user: [],
				vip: [],
				page: 1,
				zys: '',
				status: 'nomore',
			};
		},
		onLoad() {
			this.get_td();



		},
		methods: {
			change(index) {
				this.current = index;
				console.log(index);
				if (index == 0) {
					this.vip = this.user['usuperiorvip']
				} else if (index == 1){
					this.vip = this.user['usuperiorsvip']
				}else{
					this.vip = this.user['team_vip_list'];
				}
			},
			go_wen() {
				this.$.open('/pages/mine/wen?id=' + 1)
			},
			get_td(){
				this.$.ajax(1, 'post', 'index/get_team', {
					uid: uni.getStorageSync('uid'),
					token: uni.getStorageSync('token')
				}, (res) => {
					console.log(res)
					if (res.code == 1) {
						this.user = res.userinfo
						this.user.usuperiorvip.forEach((item,index)=>{
								this.vip.push(item);
							})
					} else {
						this.$.ti_shi('token已过期，请重新登陆')
						if(res.code == 9) {
							uni.clearStorageSync()
							setTimeout(() => {
								uni.navigateTo({
									url: '/pages/login/login'
								})
							}, 1000)
							return;
						}
					}
				
				})
			}
		},
		onReachBottom() {
			// var xiabiao = this.current;
			console.log(111)
			if(this.page+1 <= this.zys){
				this.status = 'loading';
				this.page = ++this.page;
				console.log(this.page)
				this.get_td();
			}else{
				this.status = 'nomore';
				return;
			}
		}
	}
</script>

<style lang="scss">
	.tg_bz {
		position: fixed;
		z-index: 999;
		font-size: 22rpx;
		line-height: 32rpx;
		top: calc(var(--status-bar-height) + 30rpx);
		right: 48rpx;
		color: #fff;

		image {
			width: 34rpx;
			height: 34rpx;
			margin-right: 6rpx;
		}

	}

	.content {
		width: 100%;
		padding: 0 24rpx 0 24rpx;
		padding-top: calc(var(--status-bar-height) + 124rpx);

		z-index: 998;

		.hy_logo {
			width: 36.29rpx;
			height: 28.88rpx;
			margin-right: 6rpx;
		}

		.hy_vip {
			font-size: 22rpx;
			line-height: 32rpx;
			color: #CA9A5A;
		}

		.hy_pt {
			font-size: 22rpx;
			line-height: 32rpx;
			color: #fff;
		}

		.top {
			width: 100%;
			padding: 38rpx 24rpx 42rpx 48rpx;
			height: 318rpx;
			position: relative;
			background-image: url(../../static/mine/td.png);
			background-size: 100% 100%;
			// padding: 36rpx 0 24rpx 48rpx;
			margin-bottom: 44rpx;
			color: #fff;
		}

		.text1 {
			font-size: 22rpx;
			line-height: 32rpx;
			margin-bottom: 14rpx;
		}

		.text2 {
			font-size: 34rpx;
			line-height: 48rpx;
			margin-bottom: 14rpx;
		}

		.ck_btn {
			width: 144rpx;
			height: 50rpx;
			border-radius: 30rpx;
			background-color: #E23C63;
			font-size: 22rpx;
		}

		.sj {
			font-size: 22rpx;
			line-height: 32rpx;
			position: absolute;
			bottom: 24rpx;
			right: 24rpx;
		}

		.bottom {
			width: 100%;
			padding: 36rpx 24rpx;
			background-color: #fff;
			box-shadow: 0rpx 6rpx 24rpx rgba(34, 34, 34, 0.05);
			border-radius: 20rpx;
			margin-bottom: 12rpx;
		}
	}
</style>
